package com.atguigu.guli.service.base.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan(basePackages = "com.atguigu.guli.service.*.mapper")
public class MyBatisConfig {
    //配置分页拦截器
    @Bean
    public PaginationInterceptor getPaginationInterceptor(){
        PaginationInterceptor interceptor = new PaginationInterceptor();
        interceptor.setOverflow(true);
        return interceptor;
    }

    //配置乐观锁拦截器
    @Bean
    public OptimisticLockerInterceptor  getOptimisticLockerInterceptor(){
        return new OptimisticLockerInterceptor();
    }

}
